<?php
/**
 * TrackMania Web Services SDK for PHP - Examples
 *
 * @copyright   Copyright (c) 2009-2011 NADEO (http://www.nadeo.com)
 * @license     http://www.gnu.org/licenses/lgpl.html LGPL License 3
 * @author      $Author: maximeraoust $:
 * @version     $Revision: 23 $:
 * @date        $Date: 2011-07-21 13:26:21 +0000 (Thu, 21 Jul 2011) $:
 */
require_once __DIR__.'/../src/autoload.php';

echo "Enter your API username:\n";
$username = trim(fgets(STDIN));

echo "Enter your API password:\n";
$password = trim(fgets(STDIN));

$players = new \TrackMania\WebServices\Players($username, $password);

while(true)
{
	try
	{
		echo "Enter a TrackMania Forever login:\n";
		$login = trim(fgets(STDIN));
		$player = $players->get($login);
		print_r($player);
	}
	catch(\TrackMania\WebServices\Exception $e)
	{
		printf('HTTP Response: %d %s', $e->getHTTPStatusCode(),
			$e->getHTTPStatusMessage());
		echo "\n";
		printf('API Response: %s (%d)', $e->getMessage(), $e->getCode());
		echo "\n";
	}
	echo "\n";
}
?>